﻿using Microsoft.Extensions.Configuration;
using System;
using NetMicro.Core.ConfigureOptions;

namespace NetMicro.Webs.DynamicWebApiController.Options
{
    /// <summary>
    /// 模块化配置
    /// </summary>
    public class ModuleSettingsOptions : IConfigOptions<ModuleSettingsOptions>
    {
        /// <summary>
        /// 配置支持的包前缀名
        /// </summary>
        public string[] SupportPackageNamePrefixs { get; set; }

        /// <summary>
        /// 是否启用引用程序集扫描
        /// </summary>
        public bool? EnabledReferenceAssemblyScan { get; set; }

        /// <summary>
        /// 外部程序集
        /// </summary>
        public string[] ExternalAssemblies { get; set; }

        /// <summary>
        /// 是否启用远程调用
        /// </summary>
        public bool? EnableRemote { get; set; }

        /// <summary>
        /// 选项后期配置
        /// </summary>
        /// <param name="options"></param>
        /// <param name="configuration"></param>
        public void PostConfigure(ModuleSettingsOptions options, IConfiguration configuration)
        {
            options.EnabledReferenceAssemblyScan ??= false;
            options.ExternalAssemblies ??= Array.Empty<string>();
            options.SupportPackageNamePrefixs ??= Array.Empty<string>();
            options.EnableRemote ??= false;

        }
    }
}
